POV-Ray : Newsgroups : povray.advanced-users : Help me with matrix please... : Re: Help me with matrix please... Server Time
30 Jul 2024 10:20:44 EDT (-0400)
  Re: Help me with matrix please...  
From: Thorsten Froehlich
Date: 26 Sep 1999 11:48:35
Message: <37ee4053@news.povray.org>
In article <37ee313a@news.povray.org> , "TonyB" 
<ben### [at] panamaphoenixnet> wrote:

> Given 2 points in 2D* or 3D space, A and B, how can I make an object rotate
> to line itself up to the line AB?

You just want the rotation, so you need to find them one after each other.
In the following I will assume the left-handed coordinate system. I will
call your vector AB = V .

First, determine the rotation between needed to the vector will be in the
xz-plane. Doing so is easy:

r = vlength(V);

so you get

sin a = V.y / r

your first angle is

a = asin(V.y / r)       // Remember: POV-Ray returns asin in radians!


Next you want the angle of the newly fromed vector (or any vector with the
same direction) with the x-axis

M = <V.x, 0, V.z>

r = vlength(M);

g = asin(M.z / r)


Now you have to angles, I guess you can figure out the rest yourself :-)


    Thorsten


____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.